package com.yl.pattern.behavioralmodel.interpreter;

/**
 * @Author 小羊
 * @Date 1/11/2024下午 8:50
 * @ClassName Plus
 * @Description 减法表达式类
 */
public class Minus extends AbstractExpression{
    /**
     * 减号左边的表达式
     */
    private AbstractExpression left;
    /**
     * 减号右边的表达式
     */
    private AbstractExpression right;

    public Minus(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    public int interpret(Context context) {
        return left.interpret(context)-right.interpret(context);
    }

    @Override
    public String toString() {
        return "("+left.toString()+"-"+right.toString()+")";
    }
}
